import java.io.IOException;
import java.util.ArrayList;


public class ReadNext 
{
	
	datatype[] datatypes = new datatype[7];
	public String readNext(long r, ArrayList<datatype> header )
	{
		heap.readpointer = r;
		datatypes[0] = new i1();
		datatypes[1] = new i2();
		datatypes[2] = new i4();
		datatypes[3] = new i8();
		datatypes[4] = new r4();
		datatypes[5] = new r8();
		datatypes[6] = new cx();
		String rec="";
		for(int i=0;i<header.size();i++)
		{
			
			try {
				rec += datatypes[header.get(i).type].read(header.get(i).length);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			rec+=",";
		}
		
		return rec.substring(0, rec.length()-1); 
		
	}

}
